package com.gl.saasservice.repository;


import com.gl.saasservice.entity.AppUser;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

public interface AppUserRepository extends PagingAndSortingRepository<AppUser, String>, JpaSpecificationExecutor<AppUser> {
    @Modifying
    @Query(value = "update saas_app_user m set m.name= ?1 ,m.phone=?2 where m.phone= ?3",nativeQuery = true)
    public int saveNameAndPhone(String name,String phone,String oldPhone);

    @Query(value = " from AppUser a where a.phone = ?1")
    public AppUser findByPhone(String phone);

    @Query(value = " from AppUser a where a.phone = ?1 and a.status = ?2  ")
    public AppUser findByPhoneAndStatus(String phone,Integer status);

    AppUser findByEnterpriseUserId(String id);
}
